<template>
  <div class="app-container home">

    <el-card class="box-card">
  <div slot="header" class="clearfix">
    <span>通知公告</span>
  </div>
  <div  class="text item">
       <el-table v-loading="loading" :data="noticeList">
     <el-table-column type="index" align="center" label="序号" />
      <el-table-column
        label="公告标题"
        align="center"
        prop="noticeTitle"
        :show-overflow-tooltip="true"
      />
      <el-table-column label="公告类型" align="center" prop="noticeType" width="100">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.sys_notice_type" :value="scope.row.noticeType"/>
        </template>
      </el-table-column>
      <el-table-column label="创建者" align="center" prop="createBy" width="100" />
      <el-table-column label="创建时间" align="center" prop="createTime" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            @click="handleDetail(scope.row)"
          >查看</el-button>
          
        </template>
      </el-table-column>
    </el-table>
       <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
   
  </div>
  <el-dialog
  title="通知公告"
  :visible.sync="dialogVisible"
  width="50%"
  >
  <h1 ><span style="font-weight: bolder;">{{ row.noticeTitle }}</span></h1>
  <div><span style="color: gray;">{{ row.createTime }}</span></div>
   <el-divider></el-divider>
  <div>
    <span v-html="row.noticeContent"></span>
  </div>
  <span slot="footer" class="dialog-footer">
    <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
  </span>
</el-dialog>
</el-card>


 
  </div>
</template>

<script>
import { listNotice} from "@/api/system/notice";
export default {
  name: "Index",
   dicts: ['sys_notice_status', 'sys_notice_type'],
  data() {
    return {
      // 公告表格数据
      noticeList: [],
      dialogVisible:false,
       // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      row:{},
       // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        noticeTitle: undefined,
        createBy: undefined,
        status: 0
      },
     
    };
  },
  created() {
    this.getList();
  },
  methods: {
    handleDetail(row){
      this.row=row
      this.dialogVisible=true

    },
     /** 查询公告列表 */
    getList() {
      this.loading = true;
      listNotice(this.queryParams).then(response => {
        this.noticeList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    
    
  }
};
</script>

<style scoped lang="scss">
.text {
    font-size: 14px;
  }

  .item {
    margin-bottom: 18px;
  }

  .clearfix:before,
  .clearfix:after {
    display: table;
    content: "";
  }
  .clearfix:after {
    clear: both
  }
 .box-card {
    margin: 20px;
  }

</style>

